home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_kernel_source / INIT / MAIN.C < prev    next >
C/C++ Source or Header  |  1999-09-17  |  34KB  |  1,384 lines

  1. /*
  2.  *  linux/init/main.c
  3.  *
  4.  *  Copyright (C) 1991, 1992  Linus Torvalds
  5.  *
  6.  *  GK 2/5/95  -  Changed to support mounting root fs via NFS
  7.  *  Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
  8.  *  Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
  9.  *  Simplified starting of init:  Michael A. Griffith <grif@acm.org> 
  10.  */
  11.  
  12. #define __KERNEL_SYSCALLS__
  13.  
  14. #include <linux/config.h>
  15. #include <linux/proc_fs.h>
  16. #include <linux/unistd.h>
  17. #include <linux/ctype.h>
  18. #include <linux/delay.h>
  19. #include <linux/utsname.h>
  20. #include <linux/ioport.h>
  21. #include <linux/init.h>
  22. #include <linux/smp_lock.h>
  23. #include <linux/blk.h>
  24. #include <linux/hdreg.h>
  25.  
  26. #include <asm/io.h>
  27. #include <asm/bugs.h>
  28.  
  29. #ifdef CONFIG_PCI
  30. #include <linux/pci.h>
  31. #endif
  32.  
  33. #ifdef CONFIG_DIO
  34. #include <linux/dio.h>
  35. #endif
  36.  
  37. #ifdef CONFIG_ZORRO
  38. #include <linux/zorro.h>
  39. #endif
  40.  
  41. #ifdef CONFIG_MTRR
  42. #  include <asm/mtrr.h>
  43. #endif
  44.  
  45. #ifdef CONFIG_APM
  46. #include <linux/apm_bios.h>
  47. #endif
  48.  
  49. /*
  50.  * Versions of gcc older than that listed below may actually compile
  51.  * and link okay, but the end product can have subtle run time bugs.
  52.  * To avoid associated bogus bug reports, we flatly refuse to compile
  53.  * with a gcc that is known to be too old from the very beginning.
  54.  */
  55. #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
  56. #error sorry, your GCC is too old. It builds incorrect kernels.
  57. #endif
  58.  
  59. extern char _stext, _etext;
  60. extern char *linux_banner;
  61.  
  62. extern int console_loglevel;
  63.  
  64. static int init(void *);
  65. extern int bdflush(void *);
  66. extern int kswapd(void *);
  67. extern int kpiod(void *);
  68. extern void kswapd_setup(void);
  69.  
  70. extern void init_IRQ(void);
  71. extern void init_modules(void);
  72. extern long console_init(long, long);
  73. extern void sock_init(void);
  74. extern void uidcache_init(void);
  75. extern void mca_init(void);
  76. extern void sbus_init(void);
  77. extern void powermac_init(void);
  78. extern void sysctl_init(void);
  79. extern void filescache_init(void);
  80. extern void signals_init(void);
  81.  
  82. extern void device_setup(void);
  83. extern void binfmt_setup(void);
  84. extern void free_initmem(void);
  85. extern void filesystem_setup(void);
  86.  
  87. #ifdef CONFIG_ARCH_ACORN
  88. extern void ecard_init(void);
  89. #endif
  90.  
  91. extern void smp_setup(char *str, int *ints);
  92. #ifdef __i386__
  93. extern void ioapic_pirq_setup(char *str, int *ints);
  94. extern void ioapic_setup(char *str, int *ints);
  95. #endif
  96. extern void no_scroll(char *str, int *ints);
  97. extern void kbd_reset_setup(char *str, int *ints);
  98. extern void panic_setup(char *str, int *ints);
  99. extern void bmouse_setup(char *str, int *ints);
  100. extern void msmouse_setup(char *str, int *ints);
  101. extern void console_setup(char *str, int *ints);
  102. #ifdef CONFIG_PRINTER
  103. extern void lp_setup(char *str, int *ints);
  104. #endif
  105. #ifdef CONFIG_JOY_AMIGA
  106. extern void js_am_setup(char *str, int *ints);
  107. #endif
  108. #ifdef CONFIG_JOY_ANALOG
  109. extern void js_an_setup(char *str, int *ints);
  110. #endif
  111. #ifdef CONFIG_JOY_ASSASIN
  112. extern void js_as_setup(char *str, int *ints);
  113. #endif
  114. #ifdef CONFIG_JOY_CONSOLE
  115. extern void js_console_setup(char *str, int *ints);
  116. #endif
  117. #ifdef CONFIG_JOY_DB9
  118. extern void js_db9_setup(char *str, int *ints);
  119. #endif
  120. #ifdef CONFIG_JOY_TURBOGRAFX
  121. extern void js_tg_setup(char *str, int *ints);
  122. #endif
  123. #ifdef CONFIG_JOY_LIGHTNING
  124. extern void js_l4_setup(char *str, int *ints);
  125. #endif
  126. extern void eth_setup(char *str, int *ints);
  127. #ifdef CONFIG_ARCNET_COM20020
  128. extern void com20020_setup(char *str, int *ints);
  129. #endif
  130. #ifdef CONFIG_ARCNET_RIM_I
  131. extern void arcrimi_setup(char *str, int *ints);
  132. #endif
  133. #ifdef CONFIG_ARCNET_COM90xxIO
  134. extern void com90io_setup(char *str, int *ints);
  135. #endif
  136. #ifdef CONFIG_ARCNET_COM90xx
  137. extern void com90xx_setup(char *str, int *ints);
  138. #endif
  139. #ifdef CONFIG_DECNET
  140. extern void decnet_setup(char *str, int *ints);
  141. #endif
  142. #ifdef CONFIG_BLK_DEV_XD
  143. extern void xd_setup(char *str, int *ints);
  144. extern void xd_manual_geo_init(char *str, int *ints);
  145. #endif
  146. #ifdef CONFIG_BLK_DEV_IDE
  147. extern void ide_setup(char *);
  148. #endif
  149. #ifdef CONFIG_PARIDE_PD
  150. extern void pd_setup(char *str, int *ints);
  151. #endif
  152. #ifdef CONFIG_PARIDE_PF
  153. extern void pf_setup(char *str, int *ints);
  154. #endif
  155. #ifdef CONFIG_PARIDE_PT
  156. extern void pt_setup(char *str, int *ints);
  157. #endif
  158. #ifdef CONFIG_PARIDE_PG
  159. extern void pg_setup(char *str, int *ints);
  160. #endif
  161. #ifdef CONFIG_PARIDE_PCD
  162. extern void pcd_setup(char *str, int *ints);
  163. #endif
  164. extern void floppy_setup(char *str, int *ints);
  165. extern void st_setup(char *str, int *ints);
  166. extern void st0x_setup(char *str, int *ints);
  167. extern void advansys_setup(char *str, int *ints);
  168. extern void tmc8xx_setup(char *str, int *ints);
  169. extern void t128_setup(char *str, int *ints);
  170. extern void pas16_setup(char *str, int *ints);
  171. extern void generic_NCR5380_setup(char *str, int *intr);
  172. extern void generic_NCR53C400_setup(char *str, int *intr);
  173. extern void generic_NCR53C400A_setup(char *str, int *intr);
  174. extern void generic_DTC3181E_setup(char *str, int *intr);
  175. extern void aha152x_setup(char *str, int *ints);
  176. extern void aha1542_setup(char *str, int *ints);
  177. extern void gdth_setup(char *str, int *ints);
  178. extern void aic7xxx_setup(char *str, int *ints);
  179. extern void AM53C974_setup(char *str, int *ints);
  180. extern void BusLogic_Setup(char *str, int *ints);
  181. extern void ncr53c8xx_setup(char *str, int *ints);
  182. extern void sym53c8xx_setup(char *str, int *ints);
  183. extern void eata2x_setup(char *str, int *ints);
  184. extern void u14_34f_setup(char *str, int *ints);
  185. extern void fdomain_setup(char *str, int *ints);
  186. extern void ibmmca_scsi_setup(char *str, int *ints);
  187. extern void in2000_setup(char *str, int *ints);
  188. extern void NCR53c406a_setup(char *str, int *ints);
  189. extern void sym53c416_setup(char *str, int *ints);
  190. extern void wd7000_setup(char *str, int *ints);
  191. extern void dc390_setup(char* str, int *ints);
  192. extern void scsi_luns_setup(char *str, int *ints);
  193. extern void scsi_logging_setup(char *str, int *ints);
  194. extern void sound_setup(char *str, int *ints);
  195. extern void reboot_setup(char *str, int *ints);
  196. extern void video_setup(char *str, int *ints);
  197. #ifdef CONFIG_CDU31A
  198. extern void cdu31a_setup(char *str, int *ints);
  199. #endif CONFIG_CDU31A
  200. #ifdef CONFIG_BLK_DEV_PS2
  201. extern void ed_setup(char *str, int *ints);
  202. extern void tp720_setup(char *str, int *ints);
  203. #endif CONFIG_BLK_DEV_PS2
  204. #ifdef CONFIG_MCD
  205. extern void mcd_setup(char *str, int *ints);
  206. #endif CONFIG_MCD
  207. #ifdef CONFIG_MCDX
  208. extern void mcdx_setup(char *str, int *ints);
  209. #endif CONFIG_MCDX
  210. #ifdef CONFIG_SBPCD
  211. extern void sbpcd_setup(char *str, int *ints);
  212. #endif CONFIG_SBPCD
  213. #ifdef CONFIG_AZTCD
  214. extern void aztcd_setup(char *str, int *ints);
  215. #endif CONFIG_AZTCD
  216. #ifdef CONFIG_CDU535
  217. extern void sonycd535_setup(char *str, int *ints);
  218. #endif CONFIG_CDU535
  219. #ifdef CONFIG_GSCD
  220. extern void gscd_setup(char *str, int *ints);
  221. #endif CONFIG_GSCD
  222. #ifdef CONFIG_CM206
  223. extern void cm206_setup(char *str, int *ints);
  224. #endif CONFIG_CM206
  225. #ifdef CONFIG_OPTCD
  226. extern void optcd_setup(char *str, int *ints);
  227. #endif CONFIG_OPTCD
  228. #ifdef CONFIG_SJCD
  229. extern void sjcd_setup(char *str, int *ints);
  230. #endif CONFIG_SJCD
  231. #ifdef CONFIG_ISP16_CDI
  232. extern void isp16_setup(char *str, int *ints);
  233. #endif CONFIG_ISP16_CDI
  234. #ifdef CONFIG_BLK_DEV_RAM
  235. static void ramdisk_start_setup(char *str, int *ints);
  236. static void load_ramdisk(char *str, int *ints);
  237. static void prompt_ramdisk(char *str, int *ints);
  238. static void ramdisk_size(char *str, int *ints);
  239. #ifdef CONFIG_BLK_DEV_INITRD
  240. static void no_initrd(char *s,int *ints);
  241. #endif
  242. #endif CONFIG_BLK_DEV_RAM
  243. #ifdef CONFIG_ISDN_DRV_ICN
  244. extern void icn_setup(char *str, int *ints);
  245. #endif
  246. #ifdef CONFIG_ISDN_DRV_HISAX
  247. extern void HiSax_setup(char *str, int *ints);
  248. #endif
  249. #ifdef CONFIG_DIGIEPCA
  250. extern void epca_setup(char *str, int *ints);
  251. #endif
  252. #ifdef CONFIG_ISDN_DRV_PCBIT
  253. extern void pcbit_setup(char *str, int *ints);
  254. #endif
  255.  
  256. #ifdef CONFIG_ATARIMOUSE
  257. extern void atari_mouse_setup (char *str, int *ints);
  258. #endif
  259. #ifdef CONFIG_DMASOUND
  260. extern void dmasound_setup (char *str, int *ints);
  261. #endif
  262. #ifdef CONFIG_ATARI_SCSI
  263. extern void atari_scsi_setup (char *str, int *ints);
  264. #endif
  265. extern void stram_swap_setup (char *str, int *ints);
  266. extern void wd33c93_setup (char *str, int *ints);
  267. extern void gvp11_setup (char *str, int *ints);
  268. extern void ncr53c7xx_setup (char *str, int *ints);
  269. #ifdef CONFIG_MAC_SCSI
  270. extern void mac_scsi_setup (char *str, int *ints);
  271. #endif
  272.  
  273. #ifdef CONFIG_CYCLADES
  274. extern void cy_setup(char *str, int *ints);
  275. #endif
  276. #ifdef CONFIG_DIGI
  277. extern void pcxx_setup(char *str, int *ints);
  278. #endif
  279. #ifdef CONFIG_RISCOM8
  280. extern void riscom8_setup(char *str, int *ints);
  281. #endif
  282. #ifdef CONFIG_SPECIALIX
  283. extern void specialix_setup(char *str, int *ints);
  284. #endif
  285. #ifdef CONFIG_DMASCC
  286. extern void dmascc_setup(char *str, int *ints);
  287. #endif
  288. #ifdef CONFIG_BAYCOM_PAR
  289. extern void baycom_par_setup(char *str, int *ints);
  290. #endif
  291. #ifdef CONFIG_BAYCOM_SER_FDX
  292. extern void baycom_ser_fdx_setup(char *str, int *ints);
  293. #endif
  294. #ifdef CONFIG_BAYCOM_SER_HDX
  295. extern void baycom_ser_hdx_setup(char *str, int *ints);
  296. #endif
  297. #ifdef CONFIG_SOUNDMODEM
  298. extern void sm_setup(char *str, int *ints);
  299. #endif
  300. #ifdef CONFIG_ADBMOUSE
  301. extern void adb_mouse_setup(char *str, int *ints);
  302. #endif
  303. #ifdef CONFIG_WDT
  304. extern void wdt_setup(char *str, int *ints);
  305. #endif
  306. #ifdef CONFIG_PARPORT
  307. extern void parport_setup(char *str, int *ints);
  308. #endif
  309. #ifdef CONFIG_PLIP
  310. extern void plip_setup(char *str, int *ints);
  311. #endif
  312. #ifdef CONFIG_HFMODEM
  313. extern void hfmodem_setup(char *str, int *ints);
  314. #endif
  315. #ifdef CONFIG_IP_PNP
  316. extern void ip_auto_config_setup(char *str, int *ints);
  317. #endif
  318. #ifdef CONFIG_ROOT_NFS
  319. extern void nfs_root_setup(char *str, int *ints);
  320. #endif
  321. #ifdef CONFIG_FTAPE
  322. extern void ftape_setup(char *str, int *ints);
  323. #endif
  324. #ifdef CONFIG_MDA_CONSOLE
  325. extern void mdacon_setup(char *str, int *ints);
  326. #endif
  327. #ifdef CONFIG_LTPC
  328. extern void ltpc_setup(char *str, int *ints);
  329. #endif
  330.  
  331. #if defined(CONFIG_SYSVIPC)
  332. extern void ipc_init(void);
  333. #endif
  334. #if defined(CONFIG_QUOTA)
  335. extern void dquot_init_hash(void);
  336. #endif
  337.  
  338. #ifdef CONFIG_MD_BOOT
  339. extern void md_setup(char *str,int *ints) __init;
  340. #endif
  341.  
  342. /*
  343.  * Boot command-line arguments
  344.  */
  345. #define MAX_INIT_ARGS 8
  346. #define MAX_INIT_ENVS 8
  347.  
  348. extern void time_init(void);
  349.  
  350. static unsigned long memory_start = 0;
  351. static unsigned long memory_end = 0;
  352.  
  353. int rows, cols;
  354.  
  355. #ifdef CONFIG_BLK_DEV_RAM
  356. extern int rd_doload;        /* 1 = load ramdisk, 0 = don't load */
  357. extern int rd_prompt;        /* 1 = prompt for ramdisk, 0 = don't prompt */
  358. extern int rd_size;        /* Size of the ramdisk(s) */
  359. extern int rd_image_start;    /* starting block # of image */
  360. #ifdef CONFIG_BLK_DEV_INITRD
  361. kdev_t real_root_dev;
  362. #endif
  363. #endif
  364.  
  365. int root_mountflags = MS_RDONLY;
  366. char *execute_command = NULL;
  367.  
  368. static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
  369. static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
  370.  
  371. char *get_options(char *str, int *ints)
  372. {
  373.     char *cur = str;
  374.     int i=1;
  375.  
  376.     while (cur && (*cur=='-' || isdigit(*cur)) && i <= 10) {
  377.         ints[i++] = simple_strtol(cur,NULL,0);
  378.         if ((cur = strchr(cur,',')) != NULL)
  379.             cur++;
  380.     }
  381.     ints[0] = i-1;
  382.     return(cur);
  383. }
  384.  
  385. static void __init profile_setup(char *str, int *ints)
  386. {
  387.     if (ints[0] > 0)
  388.         prof_shift = (unsigned long) ints[1];
  389.     else
  390.         prof_shift = 2;
  391. }
  392.  
  393.  
  394. static struct dev_name_struct {
  395.     const char *name;
  396.     const int num;
  397. } root_dev_names[] __initdata = {
  398. #ifdef CONFIG_ROOT_NFS
  399.     { "nfs",     0x00ff },
  400. #endif
  401. #ifdef CONFIG_BLK_DEV_IDE
  402.     { "hda",     0x0300 },
  403.     { "hdb",     0x0340 },
  404.     { "hdc",     0x1600 },
  405.     { "hdd",     0x1640 },
  406.     { "hde",     0x2100 },
  407.     { "hdf",     0x2140 },
  408.     { "hdg",     0x2200 },
  409.     { "hdh",     0x2240 },
  410.     { "hdi",     0x3800 },
  411.     { "hdj",     0x3840 },
  412.     { "hdk",     0x3900 },
  413.     { "hdl",     0x3940 },
  414. #endif
  415. #ifdef CONFIG_BLK_DEV_SD
  416.     { "sda",     0x0800 },
  417.     { "sdb",     0x0810 },
  418.     { "sdc",     0x0820 },
  419.     { "sdd",     0x0830 },
  420.     { "sde",     0x0840 },
  421.     { "sdf",     0x0850 },
  422.     { "sdg",     0x0860 },
  423.     { "sdh",     0x0870 },
  424.     { "sdi",     0x0880 },
  425.     { "sdj",     0x0890 },
  426.     { "sdk",     0x08a0 },
  427.     { "sdl",     0x08b0 },
  428.     { "sdm",     0x08c0 },
  429.     { "sdn",     0x08d0 },
  430.     { "sdo",     0x08e0 },
  431.     { "sdp",     0x08f0 },
  432. #endif
  433. #ifdef CONFIG_ATARI_ACSI
  434.     { "ada",     0x1c00 },
  435.     { "adb",     0x1c10 },
  436.     { "adc",     0x1c20 },
  437.     { "add",     0x1c30 },
  438.     { "ade",     0x1c40 },
  439. #endif
  440. #ifdef CONFIG_BLK_DEV_FD
  441.     { "fd",      0x0200 },
  442. #endif
  443. #ifdef CONFIG_MD_BOOT
  444.     { "md",      0x0900 },         
  445. #endif     
  446. #ifdef CONFIG_BLK_DEV_XD
  447.     { "xda",     0x0d00 },
  448.     { "xdb",     0x0d40 },
  449. #endif
  450. #ifdef CONFIG_BLK_DEV_RAM
  451.     { "ram",     0x0100 },
  452. #endif
  453. #ifdef CONFIG_BLK_DEV_SR
  454.     { "scd",     0x0b00 },
  455. #endif
  456. #ifdef CONFIG_MCD
  457.     { "mcd",     0x1700 },
  458. #endif
  459. #ifdef CONFIG_CDU535
  460.     { "cdu535",  0x1800 },
  461.     { "sonycd",  0x1800 },
  462. #endif
  463. #ifdef CONFIG_AZTCD
  464.     { "aztcd",   0x1d00 },
  465. #endif
  466. #ifdef CONFIG_CM206
  467.     { "cm206cd", 0x2000 },
  468. #endif
  469. #ifdef CONFIG_GSCD
  470.     { "gscd",    0x1000 },
  471. #endif
  472. #ifdef CONFIG_SBPCD
  473.     { "sbpcd",   0x1900 },
  474. #endif
  475. #ifdef CONFIG_BLK_DEV_PS2
  476.     { "eda",     0x2400 },
  477.     { "edb",     0x2440 },
  478. #endif
  479. #ifdef CONFIG_PARIDE_PD
  480.     { "pda",    0x2d00 },
  481.     { "pdb",    0x2d10 },
  482.     { "pdc",    0x2d20 },
  483.     { "pdd",    0x2d30 },
  484. #endif
  485. #ifdef CONFIG_PARIDE_PCD
  486.     { "pcd",    0x2e00 },
  487. #endif
  488. #ifdef CONFIG_PARIDE_PF
  489.     { "pf",        0x2f00 },
  490. #endif
  491. #if CONFIG_APBLOCK
  492.     { "apblock", APBLOCK_MAJOR << 8},
  493. #endif
  494. #if CONFIG_DDV
  495.     { "ddv", DDV_MAJOR << 8},
  496. #endif
  497.     { NULL, 0 }
  498. };
  499.  
  500. kdev_t __init name_to_kdev_t(char *line)
  501. {
  502.     int base = 0;
  503.     if (strncmp(line,"/dev/",5) == 0) {
  504.         struct dev_name_struct *dev = root_dev_names;
  505.         line += 5;
  506.         do {
  507.             int len = strlen(dev->name);
  508.             if (strncmp(line,dev->name,len) == 0) {
  509.                 line += len;
  510.                 base = dev->num;
  511.                 break;
  512.             }
  513.             dev++;
  514.         } while (dev->name);
  515.     }
  516.     return to_kdev_t(base + simple_strtoul(line,NULL,base?10:16));
  517. }
  518.  
  519. static void __init root_dev_setup(char *line, int *num)
  520. {
  521.     ROOT_DEV = name_to_kdev_t(line);
  522. }
  523.  
  524. /*
  525.  * List of kernel command line parameters. The first table lists parameters
  526.  * which are subject to values parsing (leading numbers are converted to
  527.  * an array of ints and chopped off the string), the second table contains
  528.  * the few exceptions which obey their own syntax rules.
  529.  */
  530.  
  531. struct kernel_param {
  532.     const char *str;
  533.     void (*setup_func)(char *, int *);
  534. };
  535.  
  536. static struct kernel_param cooked_params[] __initdata = {
  537. /* FIXME: make PNP just become reserve_setup */
  538. #ifndef CONFIG_KERNEL_PNP_RESOURCE
  539.     { "reserve=", reserve_setup },
  540. #else
  541.     { "reserve=", pnp_reserve_setup },
  542. #endif
  543.     { "profile=", profile_setup },
  544. #ifdef __SMP__
  545.     { "nosmp", smp_setup },
  546.     { "maxcpus=", smp_setup },
  547. #ifdef CONFIG_X86_IO_APIC
  548.     { "noapic", ioapic_setup },
  549.     { "pirq=", ioapic_pirq_setup },
  550. #endif
  551. #endif
  552. #ifdef CONFIG_BLK_DEV_RAM
  553.     { "ramdisk_start=", ramdisk_start_setup },
  554.     { "load_ramdisk=", load_ramdisk },
  555.     { "prompt_ramdisk=", prompt_ramdisk },
  556.     { "ramdisk=", ramdisk_size },
  557.     { "ramdisk_size=", ramdisk_size },
  558. #ifdef CONFIG_BLK_DEV_INITRD
  559.     { "noinitrd", no_initrd },
  560. #endif
  561. #endif
  562. #ifdef CONFIG_FB
  563.     { "video=", video_setup },
  564. #endif
  565.     { "panic=", panic_setup },
  566.     { "console=", console_setup },
  567. #ifdef CONFIG_VGA_CONSOLE
  568.     { "no-scroll", no_scroll },
  569. #endif
  570. #ifdef CONFIG_MDA_CONSOLE
  571.     { "mdacon=", mdacon_setup },
  572. #endif
  573. #ifdef CONFIG_VT
  574.     { "kbd-reset", kbd_reset_setup },
  575. #endif
  576. #ifdef CONFIG_BUGi386
  577.     { "no-hlt", no_halt },
  578.     { "no387", no_387 },
  579.     { "reboot=", reboot_setup },
  580. #endif
  581. #ifdef CONFIG_INET
  582.     { "ether=", eth_setup },
  583. #endif
  584. #ifdef CONFIG_ARCNET_COM20020
  585.     { "com20020=", com20020_setup },
  586. #endif
  587. #ifdef CONFIG_ARCNET_RIM_I
  588.     { "arcrimi=", arcrimi_setup },
  589. #endif
  590. #ifdef CONFIG_ARCNET_COM90xxIO
  591.     { "com90io=", com90io_setup },
  592. #endif
  593. #ifdef CONFIG_ARCNET_COM90xx
  594.     { "com90xx=", com90xx_setup },
  595. #endif
  596. #ifdef CONFIG_DECNET
  597.     { "decnet=", decnet_setup },
  598. #endif
  599. #ifdef CONFIG_PRINTER
  600.         { "lp=", lp_setup },
  601. #endif
  602. #ifdef CONFIG_JOY_AMIGA
  603.     { "js_am=", js_am_setup },
  604. #endif
  605. #ifdef CONFIG_JOY_ANALOG
  606.     { "js_an=", js_an_setup },
  607. #endif
  608. #ifdef CONFIG_JOY_ASSASIN
  609.     { "js_as=", js_as_setup },
  610. #endif
  611. #ifdef CONFIG_JOY_CONSOLE
  612.     { "js_console=", js_console_setup },
  613.     { "js_console2=", js_console_setup },
  614.     { "js_console3=", js_console_setup },
  615. #endif
  616. #ifdef CONFIG_JOY_DB9
  617.     { "js_db9=", js_db9_setup },
  618.     { "js_db9_2=", js_db9_setup },
  619.     { "js_db9_3=", js_db9_setup },
  620. #endif
  621. #ifdef CONFIG_JOY_TURBOGRAFX
  622.     { "js_tg=", js_tg_setup },
  623.     { "js_tg_2=", js_tg_setup },
  624.     { "js_tg_3=", js_tg_setup },
  625. #endif
  626. #ifdef CONFIG_SCSI
  627.     { "max_scsi_luns=", scsi_luns_setup },
  628.     { "scsi_logging=", scsi_logging_setup },
  629. #endif
  630. #ifdef CONFIG_JOY_LIGHTNING
  631.     { "js_l4=", js_l4_setup },
  632. #endif
  633. #ifdef CONFIG_SCSI_ADVANSYS
  634.     { "advansys=", advansys_setup },
  635. #endif
  636. #if defined(CONFIG_BLK_DEV_HD)
  637.     { "hd=", hd_setup },
  638. #endif
  639. #ifdef CONFIG_CHR_DEV_ST
  640.     { "st=", st_setup },
  641. #endif
  642. #ifdef CONFIG_BUSMOUSE
  643.     { "bmouse=", bmouse_setup },
  644. #endif
  645. #ifdef CONFIG_MS_BUSMOUSE
  646.     { "msmouse=", msmouse_setup },
  647. #endif
  648. #ifdef CONFIG_SCSI_SEAGATE
  649.     { "st0x=", st0x_setup },
  650.     { "tmc8xx=", tmc8xx_setup },
  651. #endif
  652. #ifdef CONFIG_SCSI_T128
  653.     { "t128=", t128_setup },
  654. #endif
  655. #ifdef CONFIG_SCSI_PAS16
  656.     { "pas16=", pas16_setup },
  657. #endif
  658. #ifdef CONFIG_SCSI_GENERIC_NCR5380
  659.     { "ncr5380=", generic_NCR5380_setup },
  660.     { "ncr53c400=", generic_NCR53C400_setup },
  661.     { "ncr53c400a=", generic_NCR53C400A_setup },
  662.     { "dtc3181e=", generic_DTC3181E_setup },
  663. #endif
  664. #ifdef CONFIG_SCSI_AHA152X
  665.     { "aha152x=", aha152x_setup},
  666. #endif
  667. #ifdef CONFIG_SCSI_AHA1542
  668.     { "aha1542=", aha1542_setup},
  669. #endif
  670. #ifdef CONFIG_SCSI_GDTH
  671.     { "gdth=", gdth_setup},
  672. #endif
  673. #ifdef CONFIG_SCSI_AIC7XXX
  674.     { "aic7xxx=", aic7xxx_setup},
  675. #endif
  676. #ifdef CONFIG_SCSI_BUSLOGIC
  677.     { "BusLogic=", BusLogic_Setup},
  678. #endif
  679. #ifdef CONFIG_SCSI_NCR53C8XX
  680.     { "ncr53c8xx=", ncr53c8xx_setup},
  681. #endif
  682. #ifdef CONFIG_SCSI_SYM53C8XX
  683.     { "sym53c8xx=", sym53c8xx_setup},
  684. #endif
  685. #ifdef CONFIG_SCSI_EATA
  686.     { "eata=", eata2x_setup},
  687. #endif
  688. #ifdef CONFIG_SCSI_U14_34F
  689.     { "u14-34f=", u14_34f_setup},
  690. #endif
  691. #ifdef CONFIG_SCSI_AM53C974
  692.         { "AM53C974=", AM53C974_setup},
  693. #endif
  694. #ifdef CONFIG_SCSI_NCR53C406A
  695.     { "ncr53c406a=", NCR53c406a_setup},
  696. #endif
  697. #ifdef CONFIG_SCSI_SYM53C416
  698.     { "sym53c416=", sym53c416_setup},
  699. #endif
  700. #ifdef CONFIG_SCSI_FUTURE_DOMAIN
  701.     { "fdomain=", fdomain_setup},
  702. #endif
  703. #ifdef CONFIG_SCSI_IN2000
  704.     { "in2000=", in2000_setup},
  705. #endif
  706. #ifdef CONFIG_SCSI_7000FASST
  707.     { "wd7000=", wd7000_setup},
  708. #endif
  709. #ifdef CONFIG_SCSI_IBMMCA
  710.         { "ibmmcascsi=", ibmmca_scsi_setup },
  711. #endif
  712. #if defined(CONFIG_SCSI_DC390T) && ! defined(CONFIG_SCSI_DC390T_NOGENSUPP)
  713.         { "tmscsim=", dc390_setup },
  714. #endif
  715. #ifdef CONFIG_BLK_DEV_XD
  716.     { "xd=", xd_setup },
  717.     { "xd_geo=", xd_manual_geo_init },
  718. #endif
  719. #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
  720.     { "floppy=", floppy_setup },
  721. #endif
  722. #ifdef CONFIG_BLK_DEV_PS2
  723.     { "eda=", ed_setup },
  724.     { "edb=", ed_setup },
  725.     { "tp720=", tp720_setup },
  726. #endif
  727. #ifdef CONFIG_CDU31A
  728.     { "cdu31a=", cdu31a_setup },
  729. #endif CONFIG_CDU31A
  730. #ifdef CONFIG_MCD
  731.     { "mcd=", mcd_setup },
  732. #endif CONFIG_MCD
  733. #ifdef CONFIG_MCDX
  734.     { "mcdx=", mcdx_setup },
  735. #endif CONFIG_MCDX
  736. #ifdef CONFIG_SBPCD
  737.     { "sbpcd=", sbpcd_setup },
  738. #endif CONFIG_SBPCD
  739. #ifdef CONFIG_AZTCD
  740.     { "aztcd=", aztcd_setup },
  741. #endif CONFIG_AZTCD
  742. #ifdef CONFIG_CDU535
  743.     { "sonycd535=", sonycd535_setup },
  744. #endif CONFIG_CDU535
  745. #ifdef CONFIG_GSCD
  746.     { "gscd=", gscd_setup },
  747. #endif CONFIG_GSCD
  748. #ifdef CONFIG_CM206
  749.     { "cm206=", cm206_setup },
  750. #endif CONFIG_CM206
  751. #ifdef CONFIG_OPTCD
  752.     { "optcd=", optcd_setup },
  753. #endif CONFIG_OPTCD
  754. #ifdef CONFIG_SJCD
  755.     { "sjcd=", sjcd_setup },
  756. #endif CONFIG_SJCD
  757. #ifdef CONFIG_ISP16_CDI
  758.     { "isp16=", isp16_setup },
  759. #endif CONFIG_ISP16_CDI
  760. #ifdef CONFIG_SOUND_OSS
  761.     { "sound=", sound_setup },
  762. #endif
  763. #ifdef CONFIG_ISDN_DRV_ICN
  764.     { "icn=", icn_setup },
  765. #endif
  766. #ifdef CONFIG_ISDN_DRV_HISAX
  767.        { "hisax=", HiSax_setup },
  768.        { "HiSax=", HiSax_setup },
  769. #endif
  770. #ifdef CONFIG_ISDN_DRV_PCBIT
  771.     { "pcbit=", pcbit_setup },
  772. #endif
  773. #ifdef CONFIG_ATARIMOUSE
  774.     { "atamouse=", atari_mouse_setup },
  775. #endif
  776. #ifdef CONFIG_DMASOUND
  777.     { "dmasound=", dmasound_setup },
  778. #endif
  779. #ifdef CONFIG_ATARI_SCSI
  780.     { "atascsi=", atari_scsi_setup },
  781. #endif
  782. #ifdef CONFIG_STRAM_SWAP
  783.     { "stram_swap=", stram_swap_setup },
  784. #endif
  785. #if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
  786.         || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
  787.         || defined(CONFIG_BVME6000_SCSI)
  788.         { "53c7xx=", ncr53c7xx_setup },
  789. #endif
  790. #if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
  791.         || defined(CONFIG_GVP11_SCSI)
  792.     { "wd33c93=", wd33c93_setup },
  793. #endif
  794. #if defined(CONFIG_GVP11_SCSI)
  795.     { "gvp11=", gvp11_setup },
  796. #endif
  797. #ifdef CONFIG_MAC_SCSI
  798.     { "mac5380=", mac_scsi_setup },
  799. #endif
  800. #ifdef CONFIG_CYCLADES
  801.     { "cyclades=", cy_setup },
  802. #endif
  803. #ifdef CONFIG_DIGI
  804.     { "digi=", pcxx_setup },
  805. #endif
  806. #ifdef CONFIG_DIGIEPCA
  807.     { "digiepca=", epca_setup },
  808. #endif
  809. #ifdef CONFIG_RISCOM8
  810.     { "riscom8=", riscom8_setup },
  811. #endif
  812. #ifdef CONFIG_DMASCC
  813.     { "dmascc=", dmascc_setup },
  814. #endif
  815. #ifdef CONFIG_SPECIALIX
  816.     { "specialix=", specialix_setup },
  817. #endif
  818. #ifdef CONFIG_BAYCOM_PAR
  819.     { "baycom_par=", baycom_par_setup },
  820. #endif
  821. #ifdef CONFIG_BAYCOM_SER_FDX
  822.     { "baycom_ser_fdx=", baycom_ser_fdx_setup },
  823. #endif
  824. #ifdef CONFIG_BAYCOM_SER_HDX
  825.     { "baycom_ser_hdx=", baycom_ser_hdx_setup },
  826. #endif
  827. #ifdef CONFIG_SOUNDMODEM
  828.     { "soundmodem=", sm_setup },
  829. #endif
  830. #ifdef CONFIG_WDT
  831.     { "wdt=", wdt_setup },
  832. #endif
  833. #ifdef CONFIG_PARPORT
  834.     { "parport=", parport_setup },
  835. #endif
  836. #ifdef CONFIG_PLIP
  837.     { "plip=", plip_setup },
  838. #endif
  839. #ifdef CONFIG_HFMODEM
  840.     { "hfmodem=", hfmodem_setup },
  841. #endif
  842. #ifdef CONFIG_FTAPE
  843.     { "ftape=", ftape_setup},
  844. #endif
  845. #ifdef CONFIG_MD_BOOT
  846.     { "md=", md_setup},
  847. #endif
  848. #ifdef CONFIG_ADBMOUSE
  849.     { "adb_buttons=", adb_mouse_setup },
  850. #endif
  851. #ifdef CONFIG_LTPC
  852.     { "ltpc=", ltpc_setup },
  853. #endif
  854.     { 0, 0 }
  855. };
  856.  
  857. static struct kernel_param raw_params[] __initdata = {
  858.     { "root=", root_dev_setup },
  859. #ifdef CONFIG_ROOT_NFS
  860.     { "nfsroot=", nfs_root_setup },
  861.     { "nfsaddrs=", ip_auto_config_setup },
  862. #endif
  863. #ifdef CONFIG_IP_PNP
  864.     { "ip=", ip_auto_config_setup },
  865. #endif
  866. #ifdef CONFIG_PCI
  867.     { "pci=", pci_setup },
  868. #endif
  869. #ifdef CONFIG_PARIDE_PD
  870.     { "pd.", pd_setup },
  871. #endif
  872. #ifdef CONFIG_PARIDE_PCD
  873.     { "pcd.", pcd_setup },
  874. #endif
  875. #ifdef CONFIG_PARIDE_PF
  876.     { "pf.", pf_setup },
  877. #endif
  878. #ifdef CONFIG_PARIDE_PT
  879.         { "pt.", pt_setup },
  880. #endif
  881. #ifdef CONFIG_PARIDE_PG
  882.         { "pg.", pg_setup },
  883. #endif
  884. #ifdef CONFIG_APM
  885.     { "apm=", apm_setup },
  886. #endif
  887.     { 0, 0 }
  888. };
  889.  
  890. #ifdef CONFIG_BLK_DEV_RAM
  891. static void __init ramdisk_start_setup(char *str, int *ints)
  892. {
  893.    if (ints[0] > 0 && ints[1] >= 0)
  894.       rd_image_start = ints[1];
  895. }
  896.  
  897. static void __init load_ramdisk(char *str, int *ints)
  898. {
  899.    if (ints[0] > 0 && ints[1] >= 0)
  900.       rd_doload = ints[1] & 1;
  901. }
  902.  
  903. static void __init prompt_ramdisk(char *str, int *ints)
  904. {
  905.    if (ints[0] > 0 && ints[1] >= 0)
  906.       rd_prompt = ints[1] & 1;
  907. }
  908.  
  909. static void __init ramdisk_size(char *str, int *ints)
  910. {
  911.     if (ints[0] > 0 && ints[1] >= 0)
  912.         rd_size = ints[1];
  913. }
  914. #endif
  915.  
  916. static int __init checksetup(char *line)
  917. {
  918.     int i, ints[11];
  919.  
  920. #ifdef CONFIG_BLK_DEV_IDE
  921.     /* ide driver needs the basic string, rather than pre-processed values */
  922.     if (!strncmp(line,"ide",3) || (!strncmp(line,"hd",2) && line[2] != '=')) {
  923.         ide_setup(line);
  924.         return 1;
  925.     }
  926. #endif
  927.     for (i=0; raw_params[i].str; i++) {
  928.         int n = strlen(raw_params[i].str);
  929.         if (!strncmp(line,raw_params[i].str,n)) {
  930.             raw_params[i].setup_func(line+n, NULL);
  931.             return 1;
  932.         }
  933.     }
  934.     for (i=0; cooked_params[i].str; i++) {
  935.         int n = strlen(cooked_params[i].str);
  936.         if (!strncmp(line,cooked_params[i].str,n)) {
  937.             cooked_params[i].setup_func(get_options(line+n, ints), ints);
  938.             return 1;
  939.         }
  940.     }
  941.     return 0;
  942. }
  943.  
  944. /* this should be approx 2 Bo*oMips to start (note initial shift), and will
  945.    still work even if initially too large, it will just take slightly longer */
  946. unsigned long loops_per_sec = (1<<12);
  947.  
  948. /* This is the number of bits of precision for the loops_per_second.  Each
  949.    bit takes on average 1.5/HZ seconds.  This (like the original) is a little
  950.    better than 1% */
  951. #define LPS_PREC 8
  952.  
  953. void __init calibrate_delay(void)
  954. {
  955.     unsigned long ticks, loopbit;
  956.     int lps_precision = LPS_PREC;
  957.  
  958.     loops_per_sec = (1<<12);
  959.  
  960.     printk("Calibrating delay loop... ");
  961.     while (loops_per_sec <<= 1) {
  962.         /* wait for "start of" clock tick */
  963.         ticks = jiffies;
  964.         while (ticks == jiffies)
  965.             /* nothing */;
  966.         /* Go .. */
  967.         ticks = jiffies;
  968.         __delay(loops_per_sec);
  969.         ticks = jiffies - ticks;
  970.         if (ticks)
  971.             break;
  972.     }
  973.  
  974. /* Do a binary approximation to get loops_per_second set to equal one clock
  975.    (up to lps_precision bits) */
  976.     loops_per_sec >>= 1;
  977.     loopbit = loops_per_sec;
  978.     while ( lps_precision-- && (loopbit >>= 1) ) {
  979.         loops_per_sec |= loopbit;
  980.         ticks = jiffies;
  981.         while (ticks == jiffies);
  982.         ticks = jiffies;
  983.         __delay(loops_per_sec);
  984.         if (jiffies != ticks)    /* longer than 1 tick */
  985.             loops_per_sec &= ~loopbit;
  986.     }
  987.  
  988. /* finally, adjust loops per second in terms of seconds instead of clocks */    
  989.     loops_per_sec *= HZ;
  990. /* Round the value and print it */    
  991.     printk("%lu.%02lu BogoMIPS\n",
  992.         (loops_per_sec+2500)/500000,
  993.         ((loops_per_sec+2500)/5000) % 100);
  994. }
  995.  
  996. /*
  997.  * This is a simple kernel command line parsing function: it parses
  998.  * the command line, and fills in the arguments/environment to init
  999.  * as appropriate. Any cmd-line option is taken to be an environment
  1000.  * variable if it contains the character '='.
  1001.  *
  1002.  * This routine also checks for options meant for the kernel.
  1003.  * These options are not given to init - they are for internal kernel use only.
  1004.  */
  1005. static void __init parse_options(char *line)
  1006. {
  1007.     char *next;
  1008.     int args, envs;
  1009.  
  1010.     if (!*line)
  1011.         return;
  1012.     args = 0;
  1013.     envs = 1;    /* TERM is set to 'linux' by default */
  1014.     next = line;
  1015.     while ((line = next) != NULL) {
  1016.         if ((next = strchr(line,' ')) != NULL)
  1017.             *next++ = 0;
  1018.         /*
  1019.          * check for kernel options first..
  1020.          */
  1021.         if (!strcmp(line,"ro")) {
  1022.             root_mountflags |= MS_RDONLY;
  1023.             continue;
  1024.         }
  1025.         if (!strcmp(line,"rw")) {
  1026.             root_mountflags &= ~MS_RDONLY;
  1027.             continue;
  1028.         }
  1029.         if (!strcmp(line,"debug")) {
  1030.             console_loglevel = 10;
  1031.             continue;
  1032.         }
  1033.         if (!strncmp(line,"init=",5)) {
  1034.             line += 5;
  1035.             execute_command = line;
  1036.             /* In case LILO is going to boot us with default command line,
  1037.              * it prepends "auto" before the whole cmdline which makes
  1038.              * the shell think it should execute a script with such name.
  1039.              * So we ignore all arguments entered _before_ init=... [MJ]
  1040.              */
  1041.             args = 0;
  1042.             continue;
  1043.         }
  1044.         if (checksetup(line))
  1045.             continue;
  1046.         
  1047.         /*
  1048.          * Then check if it's an environment variable or
  1049.          * an option.
  1050.          */
  1051.         if (strchr(line,'=')) {
  1052.             if (envs >= MAX_INIT_ENVS)
  1053.                 break;
  1054.             envp_init[++envs] = line;
  1055.         } else {
  1056.             if (args >= MAX_INIT_ARGS)
  1057.                 break;
  1058.             argv_init[++args] = line;
  1059.         }
  1060.     }
  1061.     argv_init[args+1] = NULL;
  1062.     envp_init[envs+1] = NULL;
  1063. }
  1064.  
  1065.  
  1066. extern void setup_arch(char **, unsigned long *, unsigned long *);
  1067.  
  1068. #ifndef __SMP__
  1069.  
  1070. /*
  1071.  *    Uniprocessor idle thread
  1072.  */
  1073.  
  1074. int cpu_idle(void *unused)
  1075. {
  1076.     for(;;)
  1077.         idle();
  1078. }
  1079.  
  1080. #define smp_init()    do { } while (0)
  1081.  
  1082. #else
  1083.  
  1084. /*
  1085.  *    Multiprocessor idle thread is in arch/...
  1086.  */
  1087.  
  1088. extern int cpu_idle(void * unused);
  1089.  
  1090. /* Called by boot processor to activate the rest. */
  1091. static void __init smp_init(void)
  1092. {
  1093.     /* Get other processors into their bootup holding patterns. */
  1094.     smp_boot_cpus();
  1095.     smp_threads_ready=1;
  1096.     smp_commence();
  1097. }        
  1098.  
  1099. #endif
  1100.  
  1101. extern void initialize_secondary(void);
  1102.  
  1103. /*
  1104.  *    Activate the first processor.
  1105.  */
  1106.  
  1107. asmlinkage void __init start_kernel(void)
  1108. {
  1109.     char * command_line;
  1110.  
  1111. #ifdef __SMP__
  1112.     static int boot_cpu = 1;
  1113.     /* "current" has been set up, we need to load it now */
  1114.     if (!boot_cpu)
  1115.         initialize_secondary();
  1116.     boot_cpu = 0;
  1117. #endif
  1118.  
  1119. /*
  1120.  * Interrupts are still disabled. Do necessary setups, then
  1121.  * enable them
  1122.  */
  1123.     printk(linux_banner);
  1124.     setup_arch(&command_line, &memory_start, &memory_end);
  1125.     memory_start = paging_init(memory_start,memory_end);
  1126.     trap_init();
  1127.     init_IRQ();
  1128.     sched_init();
  1129.     time_init();
  1130.     parse_options(command_line);
  1131.  
  1132.     /*
  1133.      * HACK ALERT! This is early. We're enabling the console before
  1134.      * we've done PCI setups etc, and console_init() must be aware of
  1135.      * this. But we do want output early, in case something goes wrong.
  1136.      */
  1137.     memory_start = console_init(memory_start,memory_end);
  1138. #ifdef CONFIG_MODULES
  1139.     init_modules();
  1140. #endif
  1141.     if (prof_shift) {
  1142.         prof_buffer = (unsigned int *) memory_start;
  1143.         /* only text is profiled */
  1144.         prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
  1145.         prof_len >>= prof_shift;
  1146.         memory_start += prof_len * sizeof(unsigned int);
  1147.         memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
  1148.     }
  1149.  
  1150.     memory_start = kmem_cache_init(memory_start, memory_end);
  1151.     sti();
  1152.     calibrate_delay();
  1153. #ifdef CONFIG_BLK_DEV_INITRD
  1154.     if (initrd_start && !initrd_below_start_ok && initrd_start < memory_start) {
  1155.         printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
  1156.             "disabling it.\n",initrd_start,memory_start);
  1157.         initrd_start = 0;
  1158.     }
  1159. #endif
  1160.     mem_init(memory_start,memory_end);
  1161.     kmem_cache_sizes_init();
  1162. #ifdef CONFIG_PROC_FS
  1163.     proc_root_init();
  1164. #endif
  1165.     uidcache_init();
  1166.     filescache_init();
  1167.     dcache_init();
  1168.     vma_init();
  1169.     buffer_init();
  1170.     signals_init();
  1171.     inode_init();
  1172.     file_table_init();
  1173. #if defined(CONFIG_SYSVIPC)
  1174.     ipc_init();
  1175. #endif
  1176. #if defined(CONFIG_QUOTA)
  1177.     dquot_init_hash();
  1178. #endif
  1179.     check_bugs();
  1180.     printk("POSIX conformance testing by UNIFIX\n");
  1181.  
  1182.     /* 
  1183.      *    We count on the initial thread going ok 
  1184.      *    Like idlers init is an unlocked kernel thread, which will
  1185.      *    make syscalls (and thus be locked).
  1186.      */
  1187.     smp_init();
  1188.     kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
  1189.     current->need_resched = 1;
  1190.      cpu_idle(NULL);
  1191. }
  1192.  
  1193. #ifdef CONFIG_BLK_DEV_INITRD
  1194. static int do_linuxrc(void * shell)
  1195. {
  1196.     static char *argv[] = { "linuxrc", NULL, };
  1197.  
  1198.     close(0);close(1);close(2);
  1199.     setsid();
  1200.     (void) open("/dev/console",O_RDWR,0);
  1201.     (void) dup(0);
  1202.     (void) dup(0);
  1203.     return execve(shell, argv, envp_init);
  1204. }
  1205.  
  1206. static void __init no_initrd(char *s,int *ints)
  1207. {
  1208.     mount_initrd = 0;
  1209. }
  1210. #endif
  1211.  
  1212. struct task_struct *child_reaper = &init_task;
  1213.  
  1214. /*
  1215.  * Ok, the machine is now initialized. None of the devices
  1216.  * have been touched yet, but the CPU subsystem is up and
  1217.  * running, and memory and process management works.
  1218.  *
  1219.  * Now we can finally start doing some real work..
  1220.  */
  1221. static void __init do_basic_setup(void)
  1222. {
  1223. #ifdef CONFIG_BLK_DEV_INITRD
  1224.     int real_root_mountflags;
  1225. #endif
  1226.  
  1227.     /*
  1228.      * Tell the world that we're going to be the grim
  1229.      * reaper of innocent orphaned children.
  1230.      *
  1231.      * We don't want people to have to make incorrect
  1232.      * assumptions about where in the task array this
  1233.      * can be found.
  1234.      */
  1235.     child_reaper = current;
  1236.  
  1237. #if defined(CONFIG_MTRR)    /* Do this after SMP initialization */
  1238. /*
  1239.  * We should probably create some architecture-dependent "fixup after
  1240.  * everything is up" style function where this would belong better
  1241.  * than in init/main.c..
  1242.  */
  1243.     mtrr_init();
  1244. #endif
  1245.  
  1246. #ifdef CONFIG_SYSCTL
  1247.     sysctl_init();
  1248. #endif
  1249.  
  1250.     /*
  1251.      * Ok, at this point all CPU's should be initialized, so
  1252.      * we can start looking into devices..
  1253.      */
  1254. #ifdef CONFIG_PCI
  1255.     pci_init();
  1256. #endif
  1257. #ifdef CONFIG_SBUS
  1258.     sbus_init();
  1259. #endif
  1260. #if defined(CONFIG_PPC)
  1261.     powermac_init();
  1262. #endif
  1263. #ifdef CONFIG_MCA
  1264.     mca_init();
  1265. #endif
  1266. #ifdef CONFIG_ARCH_ACORN
  1267.     ecard_init();
  1268. #endif
  1269. #ifdef CONFIG_ZORRO
  1270.     zorro_init();
  1271. #endif
  1272. #ifdef CONFIG_DIO
  1273.     dio_init();
  1274. #endif
  1275.  
  1276.     /* Networking initialization needs a process context */ 
  1277.     sock_init();
  1278.  
  1279.     /* Launch bdflush from here, instead of the old syscall way. */
  1280.     kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
  1281.     /* Start the background pageout daemon. */
  1282.     kswapd_setup();
  1283.     kernel_thread(kpiod, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
  1284.     kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
  1285.  
  1286. #if CONFIG_AP1000
  1287.     /* Start the async paging daemon. */
  1288.     {
  1289.       extern int asyncd(void *);     
  1290.       kernel_thread(asyncd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
  1291.     }
  1292. #endif
  1293.  
  1294. #ifdef CONFIG_BLK_DEV_INITRD
  1295.  
  1296.     real_root_dev = ROOT_DEV;
  1297.     real_root_mountflags = root_mountflags;
  1298.     if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
  1299.     else mount_initrd =0;
  1300. #endif
  1301.  
  1302.     /* Set up devices .. */
  1303.     device_setup();
  1304.  
  1305.     /* .. executable formats .. */
  1306.     binfmt_setup();
  1307.  
  1308.     /* .. filesystems .. */
  1309.     filesystem_setup();
  1310.  
  1311.     /* Mount the root filesystem.. */
  1312.     mount_root();
  1313.  
  1314. #ifdef CONFIG_UMSDOS_FS
  1315.     {
  1316.         /*
  1317.             When mounting a umsdos fs as root, we detect
  1318.             the pseudo_root (/linux) and initialise it here.
  1319.             pseudo_root is defined in fs/umsdos/inode.c
  1320.         */
  1321.         extern struct inode *pseudo_root;
  1322.         if (pseudo_root != NULL){
  1323.             current->fs->root = pseudo_root->i_sb->s_root;
  1324.             current->fs->pwd  = pseudo_root->i_sb->s_root;
  1325.         }
  1326.     }
  1327. #endif
  1328.  
  1329. #ifdef CONFIG_BLK_DEV_INITRD
  1330.     root_mountflags = real_root_mountflags;
  1331.     if (mount_initrd && ROOT_DEV != real_root_dev
  1332.         && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
  1333.         int error;
  1334.         int i, pid;
  1335.  
  1336.         pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
  1337.         if (pid>0)
  1338.             while (pid != wait(&i));
  1339.         if (MAJOR(real_root_dev) != RAMDISK_MAJOR
  1340.              || MINOR(real_root_dev) != 0) {
  1341.             error = change_root(real_root_dev,"/initrd");
  1342.             if (error)
  1343.                 printk(KERN_ERR "Change root to /initrd: "
  1344.                     "error %d\n",error);
  1345.         }
  1346.     }
  1347. #endif
  1348. }
  1349.  
  1350. static int init(void * unused)
  1351. {
  1352.     lock_kernel();
  1353.     do_basic_setup();
  1354.  
  1355.     /*
  1356.      * Ok, we have completed the initial bootup, and
  1357.      * we're essentially up and running. Get rid of the
  1358.      * initmem segments and start the user-mode stuff..
  1359.      */
  1360.     free_initmem();
  1361.     unlock_kernel();
  1362.  
  1363.     if (open("/dev/console", O_RDWR, 0) < 0)
  1364.         printk("Warning: unable to open an initial console.\n");
  1365.  
  1366.     (void) dup(0);
  1367.     (void) dup(0);
  1368.     
  1369.     /*
  1370.      * We try each of these until one succeeds.
  1371.      *
  1372.      * The Bourne shell can be used instead of init if we are 
  1373.      * trying to recover a really broken machine.
  1374.      */
  1375.  
  1376.     if (execute_command)
  1377.         execve(execute_command,argv_init,envp_init);
  1378.     execve("/sbin/init",argv_init,envp_init);
  1379.     execve("/etc/init",argv_init,envp_init);
  1380.     execve("/bin/init",argv_init,envp_init);
  1381.     execve("/bin/sh",argv_init,envp_init);
  1382.     panic("No init found.  Try passing init= option to kernel.");
  1383. }
  1384.